<template>
  <div class="tabs">
    <el-tag
      :key="tag.name"
      size="small"
      closable
      v-for="tag in tags"
      :disable-transitions="false"
      @close="handleClose(tag)"
      @click="changeMenu(tag)"
      :effect="$route.name === tag.name ? 'dark' : 'plain'"
      :class="$route.name === tag.name?'active':''"
    >{{ tag.label }}</el-tag>
  </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
  data() {
    return {
      dynamicTags: ["标签一", "标签二", "标签三"],
      inputVisible: false,
      inputValue: ""
    };
  },
  computed: {
    ...mapState({ tags: state => state.tab.tabsList })
  },
  methods: {
    ...mapMutations({
      close: "closeTab"
    }),
    handleClose(tag) {
      this.close(tag);
    },
    changeMenu(item) {
      this.$router.push({ name: item.name });
      this.$store.commit("selectMenu", item);
    }
  }
};
</script>
<style lang="scss" scoped>
.tabs {
  padding: 20px;
  .el-tag {
    width: 96px;
    height: 32px;
    background: #f9f9f9;
    text-align: center;
    font-size: 12px;
    box-shadow: 0px 1px 2px 0px #d5d7dc;
    border-radius: 4px;
    border: 1px solid #ffffff;
    margin-right: 15px;
    cursor: pointer;
    line-height: 32px;
    font-weight: 400;
    color: rgba(83, 95, 116, 0.85);
    font-family: PingFangSC-Regular, PingFang SC;
   
  }
  .el-tag.active{
    box-shadow: -1px 0px 0px 0px #EAEAEE, 0px 3px 0px 0px #9AA8CA;
    }
}
</style>
